Skip to content

feat: variant page — reverse lookup (genes/tissues a variant is an eQTL for) (#6)#34

Open
boxiangliu wants to merge 1 commit into
mainfrom
feat/variant-page
Open

feat: variant page — reverse lookup (genes/tissues a variant is an eQTL for) (#6)#34
boxiangliu wants to merge 1 commit into
mainfrom
feat/variant-page

Conversation

@boxiangliu

Copy link
Copy Markdown
Contributor

What

Closes #6. A variant page: type an rsID → see every gene × tissue where it's an eQTL (the mirror of the gene page). /search now routes rsIDs here.

How — and why no schema change (#31)

The reverse lookup needs the chromosome to use the (chrom, rs_id) composite index (a bare rs_id full-scans 138M rows → timeout). So:

  • variant_chrom(rs_id) resolves the chromosome by scanning the SNP_A-indexed 1000G LD tables (autosomes) — no external service, no DDL.
  • eqtls_for_variant(chrom, rs_id, …) then does WHERE chrom = C AND rs_id = X per shard — a ~100-row index seek, not a scan.
  • gene_by_id reverse-resolves gene symbols (reconstructs the zero-padded ENSG).

Results sorted most-significant-first; each gene links to its gene page.

Testing

ruff / mypy --strict / 100% coverage (hermetic). Verified live (read-only): rs62062621 → chr17 (1.8s) → 2,485 associations across 25 tissues / 119 genes (1.7s) → HTTP 200.

Notes for review

…TL for) (#6)

Closes #6. No schema change (see #31): resolve the rsID's chromosome, then query
the existing (chrom, rs_id) composite index.

- repository.py: variant_chrom() (resolves chromosome via the SNP_A-indexed 1000G
  LD tables), eqtls_for_variant() (fast `WHERE chrom AND rs_id` fan-out), gene_by_id()
  (reverse gencode lookup, reconstructs the zero-padded ENSG).
- web.py: GET /variant/{rsid} (reverse lookup, significant first, links each gene to
  its page); /search now routes rsIDs here.
- templates/variant.html.
- 100% coverage; verified live: rs62062621 -> chr17 -> 2485 associations / 119 genes
  across 25 tissues in ~3.5s.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Variant page: reverse lookup (genes/tissues a variant is an eQTL for)

1 participant